fun read file =
    let
        val inStream = TextIO.openIn file
    in
        (* TextIO.inputAll returns a TextIO.vector, which is a string. *)
        TextIO.inputAll inStream
    end;

val str = read "example-file.txt";
val lines = String.tokens (fn c => c = #"\n") str;
lines;


fun read_lines file =
    let
        val inStream = TextIO.openIn file
        fun iter inputStream =
            case TextIO.inputLine inputStream of
                SOME line => line :: iter inputStream
              | NONE => []
        val lines = iter inStream
    in
        TextIO.closeIn inStream;
        lines
    end;

val lines = read_lines "example-file.txt";
